import {defineComponent, ref} from 'vue';
import AntdTableWithFilter from "../../jlstarter/fn-components/ant/table/search/AddTableSearch.tsx";
import AddFormModal from "../../jlstarter/fn-components/ant/table/button/AddFormModal.tsx";
import {useAxios, useRequest} from "ahooks-vue";
import {api} from "../../utils/api-instance.ts";

export default defineComponent({
    setup() {
        const formVal = ref({});

        const formFields = [
            {label: '姓名', name: 'name', type: 'input', placeholder: '请输入姓名'},
            {label: '年龄', name: 'age', type: 'input', placeholder: '请输入年龄'},
            {label: '邮箱', name: 'email', type: 'input', placeholder: '请输入邮箱'}
        ];
        const tableData = ref([
            {id: 1, name: 'John Doe', age: 28},
            {id: 2, name: 'Jane Smith', age: 32}
        ]);

        const columns = [
            {
                title: 'Name',
                dataIndex: 'name',
                key: 'name'
            },
            {
                title: 'Age',
                dataIndex: 'age',
                key: 'age'
            }
        ];

        const filterMetadata = [
            {label: '姓名', key: 'name', placeholder: '请输入姓名', type: 'input'},
            {label: '年龄', key: 'age', placeholder: '请输入年龄', type: 'input'}
        ];

        // 处理筛选事件
        const handleFilter = (filters: any) => {
            console.log('筛选条件: ', filters);
            // 在这里可以根据筛选条件来过滤 tableData
        };

        // let useRequest1 = useRequest(Api.chatController.chat, {...person});

        let body =
            {
                modelName: "dasoidj",
                prompt: "daosij",
                sessionId: "doaisjd",
                enableVectorStore: true,
                enableFunctionCalling: true,
                cosplay: "djaois",
                fomatJson: "daosijd",
                jsonComment: "daosidj",
            }


        let options = {body: body};
        let stringPromise: Promise<string> = api.chatController.chatTest(options);



        return () => (
            <div>
                <AddFormModal v-model={formVal} fields={formFields} onSubmit={(val) => {
                    // console.log(55555,data);
                    // console.log(useRequest1.data);
                }}/>
                <AntdTableWithFilter v-model={[tableData.value, 'value']} columns={columns}
                                     filterMetadata={filterMetadata}
                                     onFilter={handleFilter}/>
            </div>
        );
    }
});